---子弹弹射到身后目标
---@class SkillEffect114102:BaseSkillEffect
SkillEffect114102 = ClientFight.CreateClass("SkillEffect114102",ClientFight.BaseSkillEffect)
local t = SkillEffect114102
function t:prepareSkill(skill ,position)
    return false
end
function t:releaseSkill(skill)
    return false
end
---@param parentSkill FightUsingSkill
---@param target Fighter
---@param triggerSkill FightUsingSkill
---@return SkillEffectResult
function t:triggerSkill(parentSkill,target,triggerSkill)
    local fight = parentSkill.fight
    local fighter = parentSkill.fighter
    local triggerSkillBean = triggerSkill.skill.skillBean
    local parentSkillBean = parentSkill.skill.skillBean
    -- 整个技能不可重复目标
    if (triggerSkillBean.f_SkillPointRepeat == SkillPointRepeatEnum.UNREPEATABLE_ALL) then
        parentSkill.excludes[parentSkill.target.fighterId] = true
    end
    --触发技能选择目标
    local targets = SkillManager.selectAttackTargets(parentSkill.fight, parentSkill.fighter,
    triggerSkill.skill, triggerSkillBean.f_TargetRange, triggerSkillBean.f_Target,
    AttackUtils.getAttackRadius(fighter, triggerSkill.skill),
    AttackUtils.getAttackShape(parentSkill.fighter, triggerSkill.skill),
    parentSkill.target.position, triggerSkillBean.f_TagActivate, parentSkill.excludes);
    if (#targets == 0) then
        SkillRoleMgr.savePathFile(
                "[" .. fight.frame .. "][SKILL]" .. parentSkill.fighter.fighterId .. "父技能"
                        + parentSkill.skill.skillBean.f_SkillID .. "子技能"
                        + triggerSkill.skill.skillId .. "因为没有目标触发技能失败");
        return SkillEffectResult.New(true,false);
    end
    SkillRoleMgr.savePathFile(
            "[" .. fight.frame .. "][SKILL]" .. parentSkill.fighter.fighterId .. "父技能"
                    .. parentSkill.skill.skillBean.f_SkillID .. "的释放者"
                    .. parentSkill.fighter.fighterId .. "(" .. parentSkill.fighter.position .. ")"
            .. ",目标" .. parentSkill.target.fighterId .. "(" .. parentSkill.target.position
            .. "),方向" .. parentSkill..targetDirection);
    -- 选择身后的目标
    local selected = {}
    for k,_fighter in pairs( targets) do
        if (FighterUtils.leftOrRight1(parentSkill.target, _fighter) == parentSkill.targetDirection) then
            SkillRoleMgr.savePathFile(
            "[" .. fight.frame .. "][SKILL]" .. parentSkill.fighter.fighterId .. "父技能"
            .. parentSkill.skill.skillBean.f_SkillID .. "子技能"
            .. triggerSkill.skill.skillId .. "可选择目标" .. _fighter.fighterId .. "("
            .. _fighter.position .. ")");
            table.insert(selected,_fighter)
        else
            SkillRoleMgr.savePathFile(
            "[" .. fight.frame .. "][SKILL]" .. parentSkill.fighter.fighterId .. "父技能"
            .. parentSkill.skill.skillBean.f_SkillID .. "子技能"
            .. triggerSkill.skill.skillId .. "不可选择目标" .. _fighter.fighterId .. "("
            .. _fighter.position .. ")");
        end
    end
    if (#selected == 0) then
        SkillRoleMgr.savePathFile( string.format("[%s][SKILL]%s父技能%s子技能%s因为没有目标触发技能失败",
                fight.frame, fighter.fighterId, parentSkillBean.f_SkillID, triggerSkillBean.f_SkillID
        ));
        return SkillEffectResult.New(true,false);
    end
    target = selected[fight:random(#selected)]

    triggerSkill.target = target

    -- 整个技能不可重复目标
    if (triggerSkillBean.f_SkillPointRepeat == SkillPointRepeatEnum.UNREPEATABLE_ALL) then
        triggerSkill.excludes = parentSkill.excludes
    end

    -- 目标不可重复
    if (triggerSkillBean.f_SkillPointRepeat ~= SkillPointRepeatEnum.REPEATABLE) then
        parentSkill.excludes[target.fighterId] = true
    end

    -- 如果非分离技能，打断所有正在使用的非分离技能
    if (triggerSkillBean.f_SkillOut ~= 1 and parentSkill.fighter.usingSkill ~= nil) then
        SkillManager.finishSkill(parentSkill.fighter.usingSkill, true, FinishSkillReasonEnum.OTHER);
    end
    if (triggerSkillBean.f_SkillOut == 1) then
        local commentInfo = ReportManager.flyToJsonString(fight, parentSkill.target, target,triggerSkill)
        table.insert(fight.actions,commentInfo)
        FightManager.playActions(commentInfo,triggerSkill)
    else
        triggerSkill.setOriginalTargetPlacePosition(Vector2.New(target.position.x,target.position.y));
        local attack = ReportManager.attackToJsonString(fight, parentSkill.fighter, target, triggerSkill, triggerSkill.speed);
        table.insert(fight.actions,attack)
        FightManager.playActions(attack)

        if (triggerSkillBean.f_Speed ~= 0 or triggerSkillBean.f_moveFrame ~= 0) then
            fighter.moveAttackAction = attack
        end
    end
    SkillManager.addSkill(fight, triggerSkill);
    local logTarget = target;
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][SKILL]" .. parentSkill.fighter.fighterId .. "对"
    .. logTarget.fighterId .. "触发技能" .. triggerSkillBean.f_SkillID);

    -- 开始释放技能
    SkillManager.prepareSkill(triggerSkill, parentSkill.position);

    -- 子技能加速
    if (parentSkill.frame < parentSkill.skipFrame) then
        triggerSkill.skipFrame = parentSkill.skipFrame - parentSkill.frame()
    end
    -- 聚光灯播放效果
    if (triggerSkill.stage ~= FightSkillStageEnum.FINISH
    and triggerSkill.frame < triggerSkill.skipFrame) then
        fight:addFrozenSkills(triggerSkill);
    end
    return SkillEffectResult.New(true,true);
end
function t:attack(skill,target)
    return false
end
function t:finishSkill(skill,breakin)
    return false
end
t.New()